	
	/*******************组织滚动************************************/
	function loveOrganization(){			//爱心组织
		getLoveOrganization();		//访问API	
	}
	function getLoveOrganization(){	//访问API
		request("GET", "/getLoveOrganization", {}, getLoveOrganizationSuccess,getLoveOrganizationError, true);
		function getLoveOrganizationSuccess(responseData){
			if(responseData.code=="1500")		//获取成功
			{			
				var loveOrgs=responseData.data;			
				var loveOrgPicture=$("#loveOrgPicture");	//组织头像大盒子
				var loveOrgName=$("#loveOrgName");	//组织姓名大盒子
				
				for(var i=0;i<loveOrgs.length&&i<4;i++){
					var oneOrgPicture=$("<img>");	//一个组织姓名
					var oneOrgName=$("<span>");	//一个组织姓名
					//260表示一个盒子的宽度
					oneOrgPicture.attr("src",loveOrgs[i].head_portrait).addClass("oneOrgPicture").css("left",30+i*260).show();
					oneOrgName.text(loveOrgs[i].short_name).addClass("oneOrgName").css("left",30+i*260);
					oneOrgPicture.attr('id',loveOrgs[i].user_id);
					oneOrgName.attr('id',loveOrgs[i].user_id);
					
					
					loveOrgPicture.append(oneOrgPicture);
					loveOrgName.append(oneOrgName);
					oneOrgPicture.click(function(){
						getOrganizationInfo($(this).attr('id'));
						ChangeTo($('#more'));
					})
					oneOrgName.click(function(){
						getOrganizationInfo($(this).attr('id'));
						ChangeTo($('#more'));
					})	
				}
			}
			else
			{
				alert(responseData.description);	
			}
		};
		function getLoveOrganizationError(){}
	}
	/*******************组织滚动************************************/
	
	
	
	/*******************宣传展示栏************************************/
	function showMoreOrg(){	//展示更过的组织
		ChangeTo($("#more"));
		$("h1").text("公益组织");
		$('#AllOrg').show().siblings().hide();	//组织展示
		getBillboard();	//获取宣传展示栏	
	}

	function getBillboard(){	//访问API
		request("GET", "/getBillboard", {}, getBillboardSuccess,getBillboardError, true);	
	}
	function getBillboardSuccess(responseData){
		if(responseData.code=="1600")		//获取成功
		{		
			$('#AllOrg').empty();		//清空
			var billboards=responseData.data;			
			for(var i=0;i<billboards.length;i++){
				var board=$("<div>");
				board.attr('id',billboards[i].owner_id);
				var src=billboards[i].publicity_pictures;
				if(billboards[i].publicity_pictures!=null)
					src+='?'+Math.random();
				var img=$("<img>").attr('src',src);	
				var span_id=$("<span>").text('id:'+billboards[i].billboard_id).attr('id','billboard_id');
				var span_owner=$("<span>").text('owner:'+billboards[i].owner_id).attr('id','owner_id');
				var span_score=$("<span>").text('score:'+billboards[i].score).attr('id','score');
				var span_title=$("<span>").text(billboards[i].publicity_title).attr('id','publicity_title');
				var span_content=$("<span>").text(billboards[i].publicity_content).attr('id','publicity_content');

				board.addClass('oneOrg');
				board.append(img);
				board.append(span_id);
				board.append(span_owner);
				board.append(span_score);
				board.append(span_title);
				board.append(span_content);

				board.click(function(){
					if($(this).attr('id')==$('#selfInfo #user_id').text())
					{
						var billboard_id=$(this).find("#billboard_id").text();
						$("h1").text("修改公益组织展示信息");
						$('#modifyOrg').show().siblings().hide();	//修改展示栏
						$('#modifyOrg #publicity_title').val('');
						$('#modifyOrg #publicity_content').val('');
						$('#modifyOrg #bgImage').val('');			//清除已选的图片
						
						$("#modifyOrg #prevBtn").click(function(){	//后退
							$("#moreOrgBtn").click();
						})

						$("#modifyOrg #modifyOrgBtn").click(function(){
							doModifyOrg(billboard_id);		//访问API
						})
					}
					else
					{
						getOrganizationInfo($(this).attr('id'));		//获取一个组织的详细信息，访问API
					}
				})	
				$('#AllOrg').append(board);	
			}
		}
		else
		{
			alert(responseData.description);	
		}
	};
	function getBillboardError(){}
	
	function getOrganizationInfo(orgId){
		request("GET", "/getOrganizationInfo/"+orgId, null, getOrganizationInfoSuccess,getOrganizationInfoError, true);	
		function getOrganizationInfoSuccess(responseData){
			if(responseData.code=="1900")		//修改成功
			{
				var userInfo=responseData.data;
				$("h1").text("组织详情");
				$("#organizationInfo #short_name").text(userInfo.short_name);
				$("#organizationInfo #user_id").text(userInfo.user_id);
				$("#organizationInfo #full_name").text(userInfo.full_name);
				$("#organizationInfo #establish_date").text(userInfo.establish_date);
				$("#organizationInfo #sign_up_date").text(userInfo.sign_up_date);
				$("#organizationInfo #chairman").text(userInfo.chairman);
				$("#organizationInfo #score").text(userInfo.score);
				$("#organizationInfo #telephone").text(userInfo.telephone);
				$("#organizationInfo #email").text(userInfo.email);
				$("#organizationInfo #address").text(userInfo.address);
				$("#organizationInfo #prevBtn").click(function(){
					$("#moreOrgBtn").click();
				})
				$('#organizationInfo').show().siblings().hide();	//修改展示栏
			}
			else
			{
				alert(responseData.description);	
			}		
		}
		function getOrganizationInfoError(){}
	}
	/*******************宣传展示栏************************************/
	
	
	/*******************修改宣传展示栏************************************/
	function doModifyOrg(billboard_id){
		var publicity_title=$("#modifyOrg #publicity_title").val();
		var publicity_content=$("#modifyOrg #publicity_content").val();
        var info={'publicity_title':publicity_title,'publicity_content':publicity_content}; 
		request("POST", "/doModifyOrg", info, modifyOrgSuccess,modifyOrgError, true);
		postData("/doModifyOrgImage","bg_image",$("#bgImage")[0].files[0],billboard_id,modifyOrgImageSuccess,modifyOrgImageError);
	}
	
	 function modifyOrgSuccess(responseData){
	 	if(responseData.code=="1800")		//修改成功
		{
			alert(responseData.description);
		}
		else
		{
			alert(responseData.description);	
		}		
	 }
	function modifyOrgError(){}
	function modifyOrgImageSuccess(responseData){
		responseData=jQuery.parseJSON(responseData);		//解码
		if(responseData.code=="1700")		//修改成功
		{
			alert(responseData.description);
//			$("#modifyOrg #modifyOrgBtn").unbind();
			$("#moreOrgBtn").click();
		}
		else
		{
			alert(responseData.description);	
		}		
	}
	function modifyOrgImageError(){}
	/*******************修改宣传展示栏************************************/
	
